<%@page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.el.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.entity.*"%>
<%@ page import="com.gzgi.framework.dataitem.*"%>
<%@ page import="com.gzgi.framework.sys.model.*"%>
<%@ page import="com.gzgi.framework.sys.util.*"%>
<%@ page import="com.gzgi.crm.context.*"%>
<%@ page import="com.gzgi.crm.report.*"%>
<%@ page import="com.gzgi.crm.service.*"%>
<%@ page import="com.gzgi.crm.model.*"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>
<%

		  String categoryKey = request.getParameter("categoryKey");
		  String seriesKey = request.getParameter("seriesKey");
		  String complexQuery = request.getParameter("complexQuery");
		  String seriesKey_unicode = request.getParameter("seriesKey_unicode");
		  String categoryKey_unicode = request.getParameter("categoryKey_unicode");  

 		  String saleLogType = null;
 		  String saleLogTypeCode = "";

		  categoryKey = RequestUtil.decodeString(categoryKey);
		  seriesKey = RequestUtil.decodeString(seriesKey);
 		  
          Map params = RequestUtil.getQueryParams(request);
		   
		  if (StringUtils.isNotBlank(complexQuery)) {
			  complexQuery = RequestUtil.decodeString(complexQuery);
 		  	  Map queryParams = JSONTools.decode(complexQuery);
			  if (queryParams != null && queryParams.size() > 0) {
				  params.putAll(queryParams);
			  }
	  	  }

		  DataItemService dataItemService = (DataItemService) ContextFactory.getBean("dataItemService");

		  Map dataMap = new HashMap();
		  List dataItemsxy = dataItemService.getDataItems("saleLogTypeCode");
		  if (dataItemsxy != null && dataItemsxy.size() > 0) {
				Iterator it009 = dataItemsxy.iterator();
				while (it009.hasNext()) {
					DataItem item = (DataItem) it009.next();
					dataMap.put(item.getName(), item.getCode());
				}
			}
 	 
			saleLogType = categoryKey;

			if (saleLogType != null && dataMap.get(saleLogType) != null) {
				saleLogTypeCode = (String) dataMap.get(saleLogType);
			}
			if(saleLogTypeCode == null){
				saleLogTypeCode = (String) dataMap.get(categoryKey_unicode);
			}
			
           //System.out.println(saleLogTypeCode);
		   params.put("x_salelog_logTypeCode", saleLogTypeCode);
		   params.put("query_x_salelog_logTypeCode", saleLogTypeCode);
           
		   complexQuery = JSONTools.encode(params);
           complexQuery = RequestUtil.encodeString(complexQuery);

%>
<script language="JavaScript">
    location.href="<%=request.getContextPath()%>/crm/saleLog.do?method=list&complexQuery=<%=complexQuery%>";
</script>